home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / demos / bike / macros / show.sci next >
Text File  |  1999-09-16  |  2KB  |  75 lines

  1. function []=show(xx,t,p,f_name)
  2. //[]=show(xx,t,p,[f_name])
  3. // Just show the bike evolution
  4. // t ans p are the spherical angles of the observation point
  5. // given in radian
  6. // f_name is the function name to use for display 
  7. // f_name can be velo1 or velo2 or velo3
  8. // !
  9. [lhs,rhs]=argn(0)
  10. if rhs <= 3 , f_name=velo1;end
  11. nstep=1;r1=0.3;  //change nstep for postscript
  12.  
  13. [nnr,nn]=size(xx);
  14. i=1:nstep:nn;
  15. //---------- position of the contact point of the rear wheel
  16. // xrear = xx(1:6,:)
  17. // theta=xrear(5,:);phi=xrear(4,:);
  18. rr=[ r1*cos(xx(5,:)).*sin(xx(4,:));
  19. -r1*cos(xx(5,:)).*cos(xx(4,:));
  20. -r1*sin(xx(5,:))];
  21. xprear=xx(1:3,:)+rr;
  22.  
  23. //------------ generation of the rear wheel
  24. nnn=24
  25. l=(1/nnn)*( 2*%pi)*(0:nnn)'
  26. dec = ones(l);sinl=r1*sin(l);cosl=r1*cos(l);
  27.  
  28. cphi1=cos(xx(4,i));
  29. sphi1=sin(xx(4,i));
  30. cthe1=cos(xx(5,i));
  31. sthe1=sin(xx(5,i));
  32. //  unused  (rotation angle of wheel)
  33. //  cpsi1=cos(xx(6,i));
  34. //  spsi1=sin(xx(6,i));
  35. xrearar = cosl*cphi1-sinl*(sphi1.*cthe1)+dec*xx(1,i);
  36. yrearar=  cosl*sphi1+sinl*(cphi1.*cthe1)+dec*xx(2,i);
  37. zrearar = sinl*sthe1+dec*xx(3,i);
  38.  
  39. //------------- the framefork
  40. xf= [ xx(1,i);2*xx(7,i)-xx(1,i);xx([15,21],i)];
  41. yf= [ xx(2,i);2*xx(8,i)-xx(2,i);xx([16,22],i)];
  42. zf= [ xx(3,i);2*xx(9,i)-xx(3,i);xx([17,23],i)];
  43. //------------- position of the contact point of the rear wheel
  44. //xfront=xx([21,22,23,18,19,20],:);
  45. //theta=xx(19,:);phi=xx(18,:);
  46. rr=[  r1*cos(xx(19,:)).*sin(xx(18,:));
  47. -r1*cos(xx(19,:)).*cos(xx(18,:));
  48. -r1*sin(xx(19,:))];
  49. xpfront=xx(21:23,:)+rr;
  50.  
  51.  
  52. //-------------- generation of the front wheel
  53. cphi1=cos(xx(18,i));
  54. sphi1=sin(xx(18,i));
  55. cthe1=cos(xx(19,i));
  56. sthe1=sin(xx(19,i));
  57. // unused
  58. //  cpsi1=cos(xx(20,i));
  59. //  spsi1=sin(xx(20,i));
  60. xfrontar = cosl*cphi1-sinl*(sphi1.*cthe1)+dec*xx(21,i);
  61. yfrontar=  cosl*sphi1+sinl*(cphi1.*cthe1)+dec*xx(22,i);
  62. zfrontar = sinl*sthe1+dec*xx(23,i);
  63. //---------------boundaries
  64. xp=[xprear,xpfront,[xf(2,:);yf(2,:);zf(2,:)]];
  65. xmin=mini(xp(1,:));xmax=maxi(xp(1,:));
  66. ymin=mini(xp(2,:));ymax=maxi(xp(2,:));
  67. if xmin <0 then xmin=1.04*xmin,else xmin=0.96*xmin;end
  68. if xmax >0 then xmax=1.04*xmax,else xmax=0.96*xmax;end
  69. if ymin <0 then ymin=1.04*ymin,else ymin=0.96*ymin;end
  70. if ymax >0 then ymax=1.04*ymax,else ymax=0.96*ymax;end
  71. zmin=mini(xp(3,:));zmax=maxi(xp(3,:));
  72. rect=[xmin,xmax,ymin,ymax,zmin,zmax]
  73. f_name();
  74.  
  75.